import axios from 'axios'
import router from '../router'

const request = axios.create({
    baseUrl='http:/localhost:9091/',
    timeout: 5000, // 超过7秒提示超时
})
// 请求拦截器
request.interceptors.request.use(
    config => {
        if(localStorage.token) {
            config.headers.token = localStorage.token;
        }
        return config;
    },
    error => {
        console.log(error);
        return Promise.reject(error);
    }
)
// 响应拦截器
request.interceptors.response.use(
    response => {
        return response.data;
    },
    error => {
        return error.response.data;
    }
)
export default request;